1. Field of the Invention!
The present invention relates to coding method and apparatus and, more particularly, to coding method and apparatus for encoding moving images.
2. Related Art!
Block coding method using inter-frame difference has been proposed as a moving image coding method. FIG. 6 shows a moving image encoding apparatus disclosed in Japanese Patent Application No. 4-64555.
In FIG. 6, reference numeral 1001 denotes an adder, into which block data in one spatial position of an image is inputted from one side and block data in an identical position on real space of a preceding image from frame memory 1004 is inputted from the other side. The adder 1001 subtracts the block data of the preceding image from the block data of the present image and outputs the subtraction result.
Numeral 1002 denotes a quantizer which performs discrete cosine transformation (DCT) to the difference block data inputted from the adder 1001, then performs zigzag scanning to the DCT data, and linearly quantizes the scanned data using a quantization step value (hereinafter, referred to as "g-value") to output quantized data.
Numeral 1003 denotes an inverse quantizer which inversely quantizes the quantized data inputted from the quantizer 1002, then performs inverse-zigzag scanning to the inverse-quantized data, and performs inverse-DCT to the scanned data to output spatial difference data.
The spatial difference data is inputted from the inverse quantizer 1003 into the frame memory 1004 in which the input data is added to already stored image data and stored as whole image data of a preceding image.
Numeral 1005 denotes an encoder which encodes a g-value inputted from g-value determination unit 1007, quantized data inputted from the quantizer 1002, a frame number and a block number. Further, the encoder 1005 time-divisionally multiplexes the code data and outputs the multiplexed data.
Numeral 1006 denotes a buffer which outputs a predetermined amount of the input multiplexed data from the encoder 1005 at a time, at transmission speed appropriate to transmission path 1008.
Numeral 1007 denotes a g-value determination unit which monitors the buffer 1006 and determines a g-value in accordance with the amount of data stored in the buffer 1006. The g-value determined by the g-value determination unit 1007 is transmitted to the encoder 1005, the quantizer 1002 and the inverse quantizer 1003. Further, if the determined g-value is different from a preceding g-value, the g-value determination unit 1007 transmits an update signal indicative of updating of g-value to the encoder 1005.
Next, the operation of the g-value determination unit 1007 will be described below.
FIG. 7 is a diagram showing the operation of the buffer 1006. The buffer 1006 has a buffer size represented by bit-rate/frame-rate. The code data inputted from input side 701 (left side in FIG. 7) is sequentially stored at an output side (right side in FIG. 7) as data 702, and sequentially outputted from output side 703 from the initially-stored data at a fixed speed.
The g-value determination unit 1007 monitors the data stored in the buffer 1006, and if the amount of data is close to empty status, the g-value determination unit 1007 determines a smaller g-value for generating more code data, while it determines a greater g-value for suppressing generation of code data if the stored data amount is close to full status. As shown in FIG. 7, if the g-value range is 2 to 64, the g-value determination unit 1007 outputs a g-value 2-64 in accordance with the storing status of the buffer 1006.
In the above moving image encoding apparatus, average coding amount per frame is limited based on the buffer size of the buffer 1006 under the g-value control by the g-value determination unit 1007. Accordingly, it is possible to output code data at a constant rate by the conventional moving image encoding apparatus.
However, the conventional apparatus has the following problem. An image usually includes a block having a large amount of information (e.g., a person performing conspicuous action in a moving image) and a block having a small amount of information (e.g., background in a moving image). When the conventional apparatus encodes the block of small information amount, coding amount is small, however, as output amount from the buffer 1006 is fixed, buffer amount gradually decreases. In order to stable the buffer amount, the g-value determination unit 1007 outputs a small g-value for generating more code data, and the buffer amount is stabilized at a point where the code-generating amount and the output amount balance.
On the other hand, when the block of large information amount is encoded, as the coding amount tends to exceed the output amount, the buffer amount gradually increases. Accordingly, the g-value determination unit 1007 outputs a greater g-value to suppress generation of code data. As a result, the buffer 1006 output is stabilized by suppressing generation of code data.
The above arrangement means fine quantization performed to a block having a small amount of information while rough quantization performed to a block having a large amount of information, which results in extreme degradation of image quality.
This problem may also occurs in still-image coding, especially when moving image coding is applied to a device such as a visual telephone.